package com.sun.demo02.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/rest")
public class RestTest {

    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    public String getTest(@PathVariable("id") Integer id){
        System.out.println("获取到GET请求。id="+id);
        return "success";
    }

    @RequestMapping(value = "/{id}",method = RequestMethod.POST)
    public String postTest(@PathVariable("id") Integer id){
        System.out.println("获取到Post请求。id="+id);
        return "success";
    }

    @RequestMapping(value = "/{id}",method = RequestMethod.DELETE)
    public String deleteTest(@PathVariable("id") Integer id){
        System.out.println("获取到Delete请求。id="+id);
        return "success";
    }

    @RequestMapping(value = "/{id}",method = RequestMethod.PUT)
    public String putTest(@PathVariable("id") Integer id){
        System.out.println("获取到Put请求。id="+id);
        return "success";
    }
}
